@extends('Admin.Layout.main')
@section('content')
    <section class="content">
        <div class="row">
            <!-- left column -->
            <div class="col-md-6">
                <!-- general form elements -->
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title">{{$data['pageOrButton']}} 用户组</h3>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    @if($data['flag'] == 1)
                        <form role="form" action="/admini/adminusergroup" method="post" id="adminusergroup-form">
                            @elseif($data['flag'] == 2)
                                <form role="form" action="/admini/adminusergroup/{{$data['editList']->id or ''}}" method="post" id="adminusergroup-form">
                                    {{ method_field('PUT') }}
                                    @endif
                                    <input type="hidden" name="_token" value="{{csrf_token()}}">
                                    <div class="box-body">
                                        <div class="form-group datadd-form-show-error has-error" <?php echo !empty($errors->all()) ? 'style="display:block;"' : '';?>><?php echo !empty($errors->all()) ? implode(' ',$errors->all()) : '';?></div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">组名称</label>
                                            <input type="text" placeholder="输入用户组名..." name="name" value="{{$data['editList']->name or ''}}" class="form-control">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">所属父级用户组</label>
                                            <select name="pid" class="form-control">
                                                <option value="0_0">顶级</option>
                                                @if(!empty($data['pidListStr']))
                                                    @foreach($data['pidListStr'] as $k => $v)
                                                        @if(!empty($data['editList']->pid) && $data['editList']->pid == $v->id)
                                                            <option value="{{$v->id or ''}}_{{$v->path or ''}}" selected="selected">{{$v->name or ''}}</option>
                                                        @else
                                                            <option value="{{$v->id or ''}}_{{$v->path or ''}}" @if(!empty($_GET['pid']) && $_GET['pid'] == $v->id) selected="selected" @endif>{{$v->name or ''}}</option>
                                                        @endif
                                                    @endforeach
                                                @endif
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">组描述</label>
                                            <textarea name="description" id="" cols="120" rows="10">{{$data['editList']->description or ''}}</textarea>
                                        </div>
                                    </div>
                                    <!-- /.box-body -->

                                    <div class="box-footer">
                                        <button class="btn btn-primary" type="submit">{{$data['pageOrButton']}}</button>
                                        <a href="/admini/adminusergroup" class="btn bg-olive">返回列表</a>
                                    </div>
                                </form>
                </div>
                <!-- /.box -->
            </div>
            <!--/.col (left) -->
        </div>
        <!-- /.row -->
    </section>
@endsection
@section('privatefooter')
    <!-- jquery-validator -->
    <script src="{{__BASE__}}/admin/plugins/jquery-validate/jquery.validate.min.js"></script>
    <script src="{{__BASE__}}/admin/plugins/jquery-validate/localization/messages_zh.min.js"></script>
    <script type="text/javascript" src="{{__BASE__}}/admin/dist/js/form-validate/adminusergroup.js"></script>
@endsection